<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<div>
    <h3>员工信息录入</h3>
</div>
<form action="shows.php" method="post">
    <table>
        <tr>
            <td>用户名:</td>
            <td><input type="text" name="names"/><span></span></td>
        </tr>
        <tr>
            <td>密码:</td>
            <td><input type="password" name="pwd"/></td>
        </tr>
        <tr>
            <td>确认密码:</td>
            <td><input type="password" id="r_password"/><span></span></td>
        </tr>
        <tr>
            <td>真实姓名:</td>
            <td><input type="text" name="realname"/></td>
        </tr>
        <tr>
            <td>工资:</td>
            <td><input type="text" name="money"/><span></span></td>
        </tr>
        <tr>
            <td></td>
            <td><button>注册</button></td>
        </tr>
    </table>
</form>
</body>
<script>
    $(function(){
        $("button").click(function(){
            var username = $("[name=names]").val();
            var password = $("[name=pwd]").val();
            var r_password = $("#r_password").val();
            var salary = $("[name=money]").val();

            var flag_name = /^[\u4e00-\u9fa5]{2,5}$/;
            if(!flag_name.test(username)){
                $("[name=money]").next().html('用户名为2到5位');
                return false;
            }else{
                $("[name=names]").next().html('√');
            }

            if(password == r_password){
                $("#r_password").next().html('√');
            }else{
                $("#r_password").next().html('两次密码不一致');
                return false;
            }

            if(salary%1 === 0){
                $("[name=money]").next().html('√');
            }else{
                $("[name=money]").next().html('必须是数字');
                return false;
            }


            $("form").submit();

        })
    })
</script>
</html>